package Car;

/**
 * @author qqq
 * @version 1.0
 * @date $(DATE)$(TIME)
 * @description
 */
public class Auto {
    protected int tireCount; // 轮胎个数
    protected String color;  // 汽车颜色
    protected double weight; // 车身重量
    protected double speed;  // 当前速度

    // 默认构造方法
    public Auto() {
        this.tireCount = 4; // 默认轮胎个数为 4
        this.color = "White"; // 默认颜色为白色
        this.weight = 1000.0; // 默认重量为 1000 kg
        this.speed = 0.0;     // 默认速度为 0
    }

    // 带参数的构造方法
    public Auto(int tireCount, String color, double weight) {
        this.tireCount = tireCount;
        this.color = color;
        this.weight = weight;
        this.speed = 0.0; // 初始速度为 0
    }

    // 加速方法
    public void accelerate(double increment) {
        if (increment > 0) {
            speed += increment;
            System.out.println("Accelerating... Current speed: " + speed + " km/h");
        } else {
            System.out.println("Invalid acceleration value.");
        }
    }

    // 减速方法
    public void decelerate(double decrement) {
        if (decrement > 0 && speed >= decrement) {
            speed -= decrement;
            System.out.println("Decelerating... Current speed: " + speed + " km/h");
        } else {
            System.out.println("Invalid deceleration value or speed is too low.");
        }
    }

    // 停车方法
    public void stop() {
        speed = 0.0;
        System.out.println("Car has stopped. Current speed: " + speed + " km/h");
    }

    // 显示汽车信息
    public void displayInfo() {
        System.out.println("Auto Info: Tire Count=" + tireCount + ", Color=" + color + ", Weight=" + weight + " kg, Speed=" + speed + " km/h");
    }
}
